﻿@inherits LayoutComponentBase
<Layout Id="reuse-tabs-layout">
    <Sider NoTrigger>
        <div class="logo" />
        <Menu Theme="MenuTheme.Dark" Mode="MenuMode.Inline">
            <MenuItem Icon="home" RouterLink="/reuse">Home</MenuItem>
            <MenuItem Icon="setting" RouterLink="/reuse/title-attribute">Page settings</MenuItem>
            <MenuItem Icon="block" RouterLink="/reuse/dynamic-title">Dynamic title</MenuItem>
            <MenuItem Icon="user" RouterLink="/reuse/singleton" RouterMatch="@NavLinkMatch.Prefix">Singleton page</MenuItem>
            <MenuItem Icon="user" RouterLink="/reuse/ignore">Ignore</MenuItem>
        </Menu>
    </Sider>
    <Layout Class="site-layout">
        <Header Class="site-layout-background" Style="padding: 0;">
            <Icon Type="@IconType.Outline.Reload" Class="trigger" OnClick="Reload" />
            Cascading RouteData: <Switch Value="Routes.CascadingRouteData" OnChange="CascadingChange"></Switch>
        </Header>
        <Breadcrumb AutoGenerate>
            <BreadcrumbItem Href="/reuse">Home</BreadcrumbItem>
        </Breadcrumb>
        <ReuseTabs Style="margin: 16px;">
            <Body>
                @Body
            </Body>
            <TabPaneTemplate>
                <Content Class="site-layout-background" Style="padding: 24px;min-height: 280px;">
                    @context.Body
                </Content>
            </TabPaneTemplate>
        </ReuseTabs>
    </Layout>
</Layout>

<style>
    #reuse-tabs-layout .trigger {
        font-size: 18px;
        line-height: 64px;
        padding: 0 24px;
        cursor: pointer;
        transition: color 0.3s;
    }

        #reuse-tabs-layout .trigger:hover {
            color: #1890ff;
        }

    #reuse-tabs-layout .logo {
        height: 32px;
        background: rgba(255, 255, 255, 0.2);
        margin: 16px;
    }

    #reuse-tabs-layout .site-layout .site-layout-background {
        background: #fff;
    }

    #reuse-tabs-layout .ant-tabs-content {
        margin-top: -16px;
        border: 1px solid #f0f0f0;
    }
</style>

@inject ReuseTabsService ReuseTabsService
@inject NavigationManager NavigationManager
@code {

    [CascadingParameter]
    private Routes Routes { get; set; }

    void Reload()
    {
        ReuseTabsService.ReloadPage();
    }

    void CascadingChange(bool value)
    {
        ReuseTabsService.CloseAll();
        Routes.SetCascadingRouteData(value);
    }
}